cmake_minimum_required(VERSION 2.8.8)
# include
include_directories(.
    ../src
    ../subprojects/spice-common
 ./vcd-common-api
 ./vcd-common-api/trace-signals
 ./vcd-common-api/vcd-conf
 ./vcd-linux-ui
 ./vcd-linux-ui/vcd-setting-window
 ./vcd-linux-ui/vcd-setting-window/setting-close
 ./vcd-linux-ui/vcd-setting-window/setting-diagnosis
 ./vcd-linux-ui/vcd-setting-window/setting-main
 ./vcd-linux-ui/vcd-setting-window/setting-network
)

set(VCD_FILES
    spicy.c
    spicy-connect.c
    spice-cmdline.c
)

aux_source_directory( vcd-common-api SRC_LIST)
aux_source_directory( vcd-common-api/trace-signals SRC_LIST)
aux_source_directory( vcd-common-api/vcd-conf SRC_LIST)
aux_source_directory( vcd-common-api/vcd-ping-impl SRC_LIST)
aux_source_directory( vcd-common-api/easylog SRC_LIST)
aux_source_directory( vcd-common-api/vcd-topbar SRC_LIST)
aux_source_directory( vcd-linux-ui SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window/setting-close SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window/setting-diagnosis SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window/setting-main SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window/setting-network SRC_LIST)
aux_source_directory( vcd-linux-ui/vcd-setting-window/setting-other SRC_LIST)
aux_source_directory( vcd-rdp SRC_LIST)

set(VCD_LINK_LINUX_LIB
 -lX11
 -lXrandr
 -lXrender
 -lXext
)

set(VCD_LINK_WIN32_LIB
    -lWs2_32
)

IF(WIN32)
set(VCD_FILES ${VCD_FILES} logo.rc)
ENDIF()

option(BUILD_TESTS "option for of build tests" OFF)
if(BUILD_TESTS)
ADD_SUBDIRECTORY(vcd-tests)
endif()

option(BUILD_VCD_USB "option for of build vcd-usb" OFF)
if(BUILD_VCD_USB)
ADD_SUBDIRECTORY(vcd-usb)
endif()

# add test
IF(0)
    add_executable("test" "test.c" ${VCD_FILES} ${SRC_LIST})
    IF(WIN32)
        target_link_libraries("test" ${COMMON_LIBS} ${VCD_LINK_WIN32_LIB})
    ELSEIF(UNIX)
        target_link_libraries("test" ${COMMON_LIBS} ${VCD_LINK_LINUX_LIB})
    ELSE()
        target_link_libraries(${TARGET} ${COMMON_LIBS})
    ENDIF()
ENDIF()

# target
add_executable(${TARGET} "vcd-main-no-ui.c" ${VCD_FILES} ${SRC_LIST})
IF(WIN32)
    target_link_libraries(${TARGET} ${COMMON_LIBS} ${VCD_LINK_WIN32_LIB})
ELSEIF(UNIX)
    target_link_libraries(${TARGET} ${COMMON_LIBS} ${VCD_LINK_LINUX_LIB})
ELSE()
    target_link_libraries(${TARGET} ${COMMON_LIBS})
ENDIF()


